<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body{
            margin: 0;
            padding: 0;
        }
        #div1{
            width: 1000px;
            height: 200px;
            overflow: hidden;
            position: relative;
        }
        ul{
            margin: 0;
            padding: 0;
            position: absolute;

        }
        ul li{
            float: left;
            list-style: none;
        }

    </style>
</head>
<body>
  <div id="div1">
      <ul>
          <li><img src="images2/1.png" alt="" width="200" height="200"></li>
          <li><img src="images2/2.png" alt="" width="200" height="200"></li>
          <li><img src="images2/3.png" alt="" width="200" height="200"></li>
          <li><img src="images2/4.png" alt="" width="200" height="200"></li>
          <li><img src="images2/5.png" alt="" width="200" height="200"></li>
      </ul>
  </div>
  <button id="btn1">向左走</button>
  <button id="btn2">向右走</button>
  <script type="text/javascript">
    var oUl = document.getElementsByTagName('ul')[0];
    var aLi = document.getElementsByTagName('li');
    var oDiv = document.getElementById('div1');
    var speed = 0;
    var timer = null;

    var oBtn1 = document.getElementById('btn1');
    var oBtn2 = document.getElementById('btn2');

    oUl.innerHTML+=oUl.innerHTML;
    oUl.style.width = aLi[0].offsetWidth*aLi.length+'px';

    function moveWall() {
        if (oUl.offsetLeft<-oUl.offsetWidth/2){
            oUl.style.left = '0';
        }
        if(oUl.offsetLeft>0){
            oUl.style.left = -oUl.offsetWidth/2+'px';
        }
        oUl.style.left = oUl.offsetLeft+speed+'px';
    }

      timer =  setInterval(moveWall,30);
      oDiv.onmouseover = function () {
          clearInterval(timer);
      }
      oDiv.onmouseout = function () {
          timer =  setInterval(moveWall,30);
      }
        oBtn1.onclick = function () {
            speed=-2;
        }
        oBtn2.onclick = function () {
            speed=2;
        }




  </script>
</body>
</html>